/**
 * Scalog - Scalog is a logging framework for the Scala programming language.
 * Copyright (C) 2009  Laurent Grangier
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.scalog;

import net.scalog.config._;
import standard._;

/**
 * Mixin for all classes which wants to add logging facilities. This trait is designed to be extended and not to be used directly. In general you will prefer using StandardLogging.
 * 
 * @author Laurent Grangier
 */
trait Logging {

  /**
   * Logs the message with the given level.
   * <p>
   * The message won't be evaluated if the log level is less than the current level.
   */
  def log(message : => Any, level : Level)(implicit logger : Logger) : Unit = log(message, null, level)(logger);
  
  /**
   * Logs the message and the throwable with the given level.
   * <p>
   * The message won't be evaluated if the log level is less than the current level.
   */
  def log(message : => Any, throwable : Throwable, level : Level)(implicit logger : Logger) : Unit = {
    if (logger.isEnabled(level)) {
      logger.log(message, throwable, level);
    }
  }
  
}
